package com.qiankan.qmsj.activity;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.qiankan.qmsj.R;
import com.qiankan.qmsj.db.UserDBHelper;

import butterknife.OnClick;

public class SettingActivity extends BaseActivity {
    public static Intent newIntent(Context context) {
        return new Intent(context, SettingActivity.class);
    }

    @Override
    public int getContentViewId() {
        return R.layout.activity_setting;
    }

    @Override
    protected void initAllMembersView(Bundle savedInstanceState) {

    }

    @OnClick(R.id.rl_product_intro)
    public void onClickIntro(View view) {
        Bundle bundle = new Bundle();
        bundle.putBoolean("hideShare", true);
        bundle.putString("title", "产品介绍");
        bundle.putString("url", "http://116.62.228.94/ProductIntroduction.html");
        startActivity(WebActivity.newIntent(this, bundle));
    }

    @OnClick(R.id.rl_business)
    public void onClickBusiness(View view) {
        Bundle bundle = new Bundle();
        bundle.putBoolean("hideShare", true);
        bundle.putString("title", "商务合作");
        bundle.putString("url", "http://116.62.228.94/BusinessCooperation.html");
        startActivity(WebActivity.newIntent(this, bundle));
    }

    @OnClick(R.id.rl_about_us)
    public void onClickAboutUs(View view) {
        Bundle bundle = new Bundle();
        bundle.putBoolean("hideShare", true);
        bundle.putString("title", "关于我们");
        bundle.putString("url", "http://116.62.228.94/AboutUs.html");
        startActivity(WebActivity.newIntent(this, bundle));
    }

    @OnClick(R.id.rl_settingPwd)
    public void onClickSettingPwd(View view) {
        startActivity(SettingPasswordActivity.newIntent(this));
    }

    @OnClick(R.id.btn_logOut)
    public void logOut(View view) {
        new AlertDialog.Builder(SettingActivity.this)
                .setMessage("退出登录？")
                .setPositiveButton("确定",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                UserDBHelper.getInstance(SettingActivity.this).logoutUserInfo();
                                finish();
                            }
                        })
                .setNegativeButton("取消", null)
                .setCancelable(false)
                .show();
    }

    @OnClick(R.id.iv_back)
    public void onClickBack(View view) {
        finish();
    }
}
